//部分控制器
var app = angular.module('myApp.controllers');

//example首页
app.controller('focusStoreIndex', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {

    // 模拟数据
    $scope.shopList = [
        {id:'1',isEdit: false},
        {id:'2',isEdit: false}
    ]
    //点击去编辑
    $scope.toEdit = function (index) {
        $scope.shopList[index]['isEdit'] = true;
    }
    // 点击去详情
    $scope.toDetail = function (index, id) {
        if ($scope.shopList[index]['isEdit']) {
            $scope.shopList[index]['isEdit'] = false;
        } else {
            //跳转至详情
            console.log(1)
            utilService.$state.go('shop.detail');
        }
    }
    // 取消关注
    $scope.cancelFocus = function (id) {
        console.log('取消')
    }

    // 点击退出搜索
    $scope.isSearch = false;
    $scope.toggleSearch = function () {
        $scope.isSearch = !$scope.isSearch;
    }
    $scope.$on('$ionicView.beforeEnter', function () {
        //页面刚加载
        utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
    }, false);
    $scope.$on('$ionicView.afterEnter', function () {
        utilService.$rootScope.rootData.title = '车友中心';
        //页面加载完成
        utilService.$ionicLoading.hide();
    }, false);
    $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
        //页面离开之前
        //alertPopup && alertPopup.close();

    }, false);

}]);
